<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns="http://www.w3.org/TR/REC-html40">
<head>
  <meta content="text/html; charset=ISO-8859-1"
 http-equiv="content-type">
  <link rel="File-List" href="eqeditor_archivos/filelist.xml">

  <title>Equation editor</title>
	<!--[if !mso]>
	<style>
v\:*         { behavior: url(#default#VML) }
o\:*         { behavior: url(#default#VML) }
.shape       { behavior: url(#default#VML) }
</style>
	<![endif]--><!--[if gte mso 9]>
	<xml><o:shapedefaults v:ext="edit" spidmax="1027"/>
	</xml><![endif]-->
</head>
<body>
<img style="width: 490px; height: 93px;" src="images/gar_logo.JPG"
 alt=""><div style="margin-left: 40px;"><a name="TOP"></a><span lang="en-us">5. 
	<a href="#5._Equation_Editor">Equation Editor</a></span><div style="margin-left: 40px;">
		<span lang="en-us">5.1. <a href="#5.1._Interface_Blocks">Interface Blocks</a></span><div style="margin-left: 40px;">
			<span lang="en-us">5.1.1. <a href="#5.1.1._Menu_and_Toolbar">Menu and Toolbar</a><br>
5.1.2. <a href="#5.1.2._System_Information">System Information</a></span></div>
</div>
<div style="margin-left: 40px;"><span lang="en-us">5.2. 
	<a href="#5.2._Writing_an_equation">Writing an equation</a></span><div style="margin-left: 40px;">
		<span lang="en-us">5.2.1. <a href="#5.2.1._Variable_Declaration">Variable Declaration</a><br>
5.2.2. <a href="#5.2.3._Equation_Syntax">Equation Syntax</a></span></div>
</div>
<div style="margin-left: 40px;"><span lang="en-us">5.3 
	<a href="#5.3_Complete_example">Complete example</a> </span></div>
	<p>&nbsp;</p>
	<hr>
	<p><b><span lang="en-us"><a name="5._Equation_Editor">5. Equation Editor</a></span></b></p>
	<p><span lang="en-us">The equation editor is an editor for writing 
	differential equations in state mode for any of the embedded systems in 
	VISUNS.<br>
	</span>From the GUI, the Equation Editor is opened by clicking in the
	<img border="0" src="eqeditor_archivos/ee1.jpg" width="31" height="26"> button.</p>
	<p><span lang="en-us"><br>
	<br></span><!--[if gte vml 1]><v:shapetype id="_x0000_t202"
 coordsize="21600,21600" o:spt="202" path="m,l,21600r21600,l21600,xe">
 <v:stroke joinstyle="miter"/>
 <v:path gradientshapeok="t" o:connecttype="rect"/>
</v:shapetype><v:shape id="_x0000_s1031" type="#_x0000_t202" style='position:absolute;
 left:200.25pt;top:382.5pt;width:87.75pt;height:29.25pt;z-index:2'>
 <v:textbox>
<table cellspacing="0" cellpadding="0" width="100%" height="100%">
	<tr>
		<td align="center">Workspace</td>
	</tr>
</table>
 </v:textbox>
</v:shape><![endif]--><![if !vml]><span style='mso-ignore:vglayout;position:
absolute;z-index:2;left:266px;top:509px;width:123px;height:45px'><img
width=123 height=45 src="eqeditor_archivos/image001.gif"
alt="Cuadro de texto: Workspace&#13;&#10;" v:shapes="_x0000_s1031"></span><![endif]><!--[if gte vml 1]><v:shape
 id="_x0000_s1030" type="#_x0000_t202" href="#5.1.2._System_Information"
 style='position:absolute;left:326.25pt;top:382.5pt;width:114.75pt;height:29.25pt;
 z-index:2'>
 <v:textbox>
<table cellspacing="0" cellpadding="0" width="100%" height="100%">
	<tr>
		<td align="center">System information</td>
	</tr>
</table>
 </v:textbox>
</v:shape><![endif]--><![if !vml]><span style='mso-ignore:vglayout;position:
absolute;z-index:2;left:434px;top:509px;width:159px;height:45px'><a
href="#5.1.2._System_Information"><img border=0 width=159 height=45
src="eqeditor_archivos/image002.gif" alt="Cuadro de texto: System information&#13;&#10;"
v:shapes="_x0000_s1030"></a></span><![endif]><!--[if gte vml 1]><v:shape id="_x0000_s1029"
 type="#_x0000_t202" href="#5.1.1._Menu_and_Toolbar" style='position:absolute;
 left:65.25pt;top:384.75pt;width:110.25pt;height:29.25pt;z-index:4'>
 <v:textbox>
<table cellspacing="0" cellpadding="0" width="100%" height="100%">
	<tr>
		<td align="center">Menu and Toolbar</td>
	</tr>
</table>
 </v:textbox>
</v:shape><![endif]--><![if !vml]><span style='mso-ignore:vglayout;position:
absolute;z-index:4;left:86px;top:512px;width:153px;height:45px'><a
href="#5.1.1._Menu_and_Toolbar"><img border=0 width=153 height=45
src="eqeditor_archivos/image003.gif" alt="Cuadro de texto: Menu and Toolbar&#13;&#10;"
v:shapes="_x0000_s1029"></a></span><![endif]><!--[if gte vml 1]><v:line id="_x0000_s1028"
 style='position:absolute;left:0;text-align:left;top:0;z-index:3' from="119.25pt,411.75pt"
 to="119.25pt,488.25pt">
 <v:stroke endarrow="block"/>
</v:line><![endif]--><![if !vml]><span style='mso-ignore:vglayout;position:
absolute;z-index:3;left:153px;top:548px;width:12px;height:105px'><img width=12
height=105 src="eqeditor_archivos/image004.gif" v:shapes="_x0000_s1028"></span><![endif]><!--[if gte vml 1]><v:line
 id="_x0000_s1026" style='position:absolute;left:0;text-align:left;top:0;
 z-index:1' from="240.75pt,413.25pt" to="240.75pt,543.75pt">
 <v:stroke endarrow="block"/>
</v:line><![endif]--><![if !vml]><span style='mso-ignore:vglayout;position:
absolute;z-index:1;left:315px;top:550px;width:12px;height:177px'><img width=12
height=177 src="eqeditor_archivos/image005.gif" v:shapes="_x0000_s1026"></span><![endif]><!--[if gte vml 1]><v:line
 id="_x0000_s1025" style='position:absolute;left:0;text-align:left;top:0;
 z-index:1' from="382.5pt,408.75pt" to="382.5pt,546pt">
 <v:stroke endarrow="block"/>
</v:line><![endif]--><![if !vml]><span style='mso-ignore:vglayout;position:
absolute;z-index:1;left:504px;top:544px;width:12px;height:186px'><img width=12
height=186 src="eqeditor_archivos/image006.gif" v:shapes="_x0000_s1025"></span><![endif]><span lang="en-us"><br>
	<br><br><br><br><br>
	<img border="0" src="eqeditor_archivos/eqeditor.JPG" width="629" height="700"><br>
	</span><span lang="en-us"><br></span></p>
	<p align="right"><span lang="en-us"><i><a href="#TOP">Back to top</a></i></span></p>
	<hr>
	<div style="margin-left: 40px;"><b><span lang="en-us">
		<a name="5.1._Interface_Blocks">5.1. Interface Blocks</a></span></b><span lang="en-us"><br>
	<br>The equation editor is composed of tree block. The menu and toolbar for 
		basic functions like copy, paste or save, The system information, this 
		is where user can see all the input and output variable he can or must 
		use and The space where the user write the equation.<br></span>This is an example loading the Cartpole system. 
			As depicted in the previous Figure, the Equation Editor has been 
			loaded with the define template of Cartpole system parameters. In 
			the left side, each title indicates the defined space to create 
			variables, matrices vectors, write the program, etc. The right side 
			shows the system variable used in the Cartpole dynamic model, etc. 
			Just by using the indicate letter that defined a variable, the 
			parameters of the system can be used. </div></div>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
	The toolbar contains the necessary functions to write an edit code:&nbsp;&nbsp;<img border="0" src="eqeditor_archivos/ee3.jpg" width="266" height="56">&nbsp; , 
	it means, the user can use keyboard shortcuts as copy (CTRL+c)&nbsp;and<span lang="en-us"><br></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; paste(CTRL+v), etc. The user can also save its own code, and the system 
	will automatically save the equation in the respective folder of the 
	simulated system.<span lang="en-us"><i><br></i></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
	(For this example, the equation will be saved in the Cartpole's folder.).
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img border="0" src="eqeditor_archivos/ee4.jpg" width="200" height="182"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<img border="0" src="eqeditor_archivos/ee5.jpg" width="200" height="166"></p>
<div style="margin-left: 40px;">
	<div style="margin-left: 40px;"><p align="right"><span lang="en-us"><i><a href="#TOP">Back to top</a></i></span></p>
		<hr>
		<div style="margin-left: 40px;"><b><span lang="en-us">
			<a name="5.1.1._Menu_and_Toolbar">5.1.1. Menu and Toolbar</a></span></b><span lang="en-us"><br>
	<br>This is common functions of an editor are. Some functions are in both 
			menu and toolbar. All the functions have assigned keyboard shortcuts<br>
			<br>
			<img border="0" src="../interface/images/stock_new.png" width="24" height="24">&nbsp;&nbsp;&nbsp; 
			New equation (Ctrl+N)<br>
			<img border="0" src="../interface/images/open.png" width="24" height="24">&nbsp;&nbsp;&nbsp; 
			Open equation (Ctrl+O)<br>
			<img border="0" src="../interface/images/save32.png" width="24" height="24">&nbsp;&nbsp;&nbsp; 
			Save equation (Ctrl+S)<br>
			<img border="0" src="../interface/images/save32.png" width="24" height="24">&nbsp;&nbsp;&nbsp; 
			Save equation as (Only in menu) (Shift+Ctrl+N)<br>
			<img border="0" src="../interface/images/cut.png" width="24" height="24">&nbsp;&nbsp;&nbsp; 
			Cut Selection (Ctrl+X)<br>
			<img border="0" src="../interface/images/copy.png" width="24" height="24">&nbsp;&nbsp;&nbsp; 
			Copy Selection (Ctrl+C)<br>
			<img border="0" src="../interface/images/paste.png" width="24" height="24">&nbsp;&nbsp;&nbsp; 
			Paste Selection (Ctrl+V)<br>
			<img border="0" src="../interface/images/delete.png" width="24" height="24">&nbsp;&nbsp;&nbsp; 
			Delete Selection (Only in menu) (Del)<br>
			<img border="0" src="../interface/images/exit.png" width="24" height="24">&nbsp;&nbsp;&nbsp; 
			Quit Editor (Ctrl+Q)<br>
			<img border="0" src="../interface/images/help.png" width="24" height="24">&nbsp;&nbsp;&nbsp; 
			About</span> <span lang="en-us">(F1)</span><p align="right"><span lang="en-us"><i><a href="#TOP">Back to 
			top</a></i></span></p>
			<hr>
			<p align="justify"><b><span lang="en-us"><a name="5.1.2._System_Information">5.1.2. System 
			Information</a></span></b><span lang="en-us"><br><br>The system 
			information is very important because system variables may change 
			from system to system. It is divided into input and output 
			variables. <br><br>Input variables are divided in two kind, system 
			dependants and independents. System dependant variables are related 
			with dynamic and motor model parameters, the quantity and name may 
			vary from system to system. However simulation, controller 
			parameters variables names are the same for any system. These 
			parameters are normally not used in a controller. The main input is 
			the state of the system. For this user may use either the state 
			matrix (witch includes all past values), or the state vector (i 
			column of state matrix). The number of rows of state matrix and 
			vector is equal to the dynamic model, controller and swing up orders 
			added.<br><br>There are two output variables, U and dX. U is the 
			control effort and dX is the derivate of state. The use or not of dX 
			depends on the order or the controller. </span></p>
			<p>
			<img border="0" src="eqeditor_archivos/ee6.jpg" width="309" height="438"><br>
			&nbsp;</p>
			<p>In this first section, The system variable template allows to the 
			user to use the parameters embedded into the dynamic model. For 
			example, as shown in the previous Figure, M1 corresponds to the Cart 
			mass, then when the user is going to write a control law, and the 
			Cart mass is required, the user can use M1 in the code. Other INPUT 
			variables are also available: Motor parameters included, Simulation 
			parameters (initial time, final time, step), etc.</p>
			<p>
			<img border="0" src="eqeditor_archivos/ee7.jpg" width="355" height="233"></p>
			<p align="justify">This second section is related with the variable 
			state information. Xm corresponds to the complete variable state X. The user just types Xm(1,i) to use the cart position at&nbsp; 
			time i-1 if it is required, then, the normal use of this vector 
			corresponds to X(1)...X(n).</p>
			<p align="right"><span lang="en-us"><i><a href="#TOP">Back to top</a></i></span></p>
			<hr>
			</div></div>
	<div style="margin-left: 40px;"><p><b><span lang="en-us">
		<a name="5.2._Writing_an_equation">5.2. Writing an equation</a></span></b><span lang="en-us"><br><br>
		Before writing an equation it is imperative to understand the template. 
		It is basically divided in two parts: Variable declarations and 
		equations.&nbsp; </span></p>
		<p align="right">
		<span lang="en-us"><i><a href="#TOP">Back to top</a></i></span></p>
		<hr>
		<div style="margin-left: 40px;"><b><span lang="en-us">
			<a name="5.2.1._Variable_Declaration">5.2.1. Variable Declaration</a></span></b><span lang="en-us"><br><br>
			The most common type of variables: INT, DOUBLE, 
			ColumnVector, RowVector and Matrix.<br>To declare an INT or 
			DOUBLE, simply write the variables name separated with spaces under 
			the&nbsp; according template comment. Vector and matrix are the same 
			except that you have to specify the size. For vectors: vectorname(n), 
			for matrix: matrixname(n,m). The Following example illustrates how 
			to do it:</span><p>
			<img border="0" src="eqeditor_archivos/ee8.jpg" width="620" height="162"></p>
			<p align="right">
			<span lang="en-us"><i><a href="#TOP">Back to top</a></i></span></p>
			<hr>
			<p><b><span lang="en-us"><a name="5.2.3._Equation_Syntax">5.2.32. Equation Syntax</a></span></b><span lang="en-us"><br><br>
			VISUNS dynamic core is made in c++ with a matrix library called 
			newmat, therefore equation syntax is based on c++ and newmat. Very 
			few thing are changed respect to c++, those will be mentioned 
			further on in this chapter.</span></p>
			<table border="1" width="30%" id="table1" height="330">
				<tr>
					<td width="200"><span lang="en-us"><b>Basic </b></span><b>
					<span lang="en-us">Operations</span></b></td>
					<td><b><span lang="en-us">VISUNS editor</span></b></td>
				</tr>
				<tr>
					<td width="200"><span lang="en-us">Addition</span></td>
					<td><span lang="en-us">+</span></td>
				</tr>
				<tr>
					<td width="200"><span lang="en-us">Subtraction</span></td>
					<td><span lang="en-us">-</span></td>
				</tr>
				<tr>
					<td width="200"><span lang="en-us">Multiplication</span></td>
					<td>*</td>
				</tr>
				<tr>
					<td width="200"><span lang="en-us">Division</span></td>
					<td>/</td>
				</tr>
				<tr>
					<td width="200"><span lang="en-us">Residual division</span></td>
					<td>%</td>
				</tr>
				<tr>
					<td width="200"><span lang="en-us">DOT product of A and B</span></td>
					<td>dot(A,B)</td>
				</tr>
				<tr>
					<td width="200"><span lang="en-us">Assignment</span></td>
					<td>=</td>
				</tr>
				<tr>
					<td width="200"><span lang="en-us">Matrix A element i,j</span></td>
					<td>A(i,j)</td>
				</tr>
				<tr>
					<td width="200">Vector V element i</td>
					<td>V(i)</td>
				</tr>
				<tr>
					<td width="200">Matrix row i</td>
					<td>A.Row(i)</td>
				</tr>
				<tr>
					<td width="200">Matrix column i</td>
					<td>A.Column(i)</td>
				</tr>
				<tr>
					<td width="200">Matrix A transpose</td>
					<td>A.t()</td>
				</tr>
				<tr>
					<td width="200">&nbsp;</td>
					<td>&nbsp;</td>
				</tr>
			</table>
			<p><span lang="en-us"><br><i><b>note:</b> All indexes in matrix and 
			vector start in one (1) </i></span></p>
			<p align="right"><span lang="en-us"><i><a href="#TOP">Back to top</a></i></span></p>
			<hr>
			</div></div>
	<div style="margin-left: 40px;"><b><span lang="en-us">
		<a name="5.3_Complete_example">5.3 Complete example</a></span></b><p>The 
		following example has been tested with the Pendubot system. As mentioned 
		before, in the first section the user just defines the local variables 
		to use inside the program. After the &quot;#program&quot; template, the user 
		starts typing the equations and the variables from the system 
		information can also be used. This complete examples uses cos() and 
		sin() functions, conditionals (if), and finally the control law denoted 
		by U can be established.</p>
		<p>
		<img border="0" src="eqeditor_archivos/ee9.jpg" width="684" height="601"><img border="0" src="eqeditor_archivos/ee10.jpg" width="702" height="227"></p>
		<p align="right">
		<span lang="en-us"><i><a href="#TOP">Back to top</a></i></span></p>
		<hr>
		</div></div>
</body>
</html>
